package 蓝桥算法;

public class diamond {
    public static void main(String[] args) {
        int num = 9;
        String diamond = "";

        for (int i = 1; i <= num; i += 2) {
            String spaces = " ".repeat((num - i) / 2);
            String stars = "*".repeat(i);
            diamond += spaces + stars + "\n";
        }
        for (int i = num - 2; i >= 1; i -= 2) {
            String spaces = " ".repeat((num - i) / 2);
            String stars = "*".repeat(i);
            diamond += spaces + stars + "\n";
        }
        System.out.println(diamond);
    }
}
